﻿namespace Microsoft.ExternalResearch.CreativeCommons.Common
{
    using System;
    using System.Drawing;

    /// <summary>
    /// Represents a license.
    /// </summary>
    public class LicenseInfo
    {
        /// <summary>
        /// ID of the license.
        /// </summary>
        private string id;

        /// <summary>
        /// Url of the license.
        /// </summary>
        private string licenseUrl;

        /// <summary>
        /// XML of the license.
        /// </summary>
        private string licenseXml;

        /// <summary>
        /// Image that represent the license.
        /// </summary>
        private Image image = null;

        /// <summary>
        /// Gets or sets the ID of the license. This ID can be used to retrieve the license information from the
        /// Creative Commons API web.
        /// </summary>
        public string Id
        {
            get { return this.id; }
            set { this.id = value; }
        }

        /// <summary>
        /// Gets or sets the URL of the license. This URL can be used to retrieve the license information from the
        /// Creative Commons API web.
        /// </summary>
        public string LicenseUrl
        {
            get { return this.licenseUrl; }
            set { this.licenseUrl = value; }
        }

        /// <summary>
        /// Gets or sets the XML of the license. This XML contains all the information about the license.
        /// </summary>
        public string LicenseXml
        {
            get { return this.licenseXml; }
            set { this.licenseXml = value; }
        }

        /// <summary>
        /// Gets the image that represents the license.
        /// </summary>
        public Image Image
        {
            get
            {
                if (null == this.image)
                {
                    this.image = Helper.GetImageFromFile(Helper.LocalLicensesFolderPath + @"\" + this.Id + @"\" + Helper.LicenseImageFileName);
                }

                return this.image;
            }
        }
    }
}
